﻿namespace FirstMiddleware
{
    public class TestAPIMiddleware
    {
        private readonly RequestDelegate next;

        public TestAPIMiddleware(RequestDelegate next)
        {
            this.next = next;
        }

        public async Task InvokeAsync(HttpContext context)
        {
            //string skey = context.Request.Query["skey"];
            string skey = context.Request.Headers["skey"];

            if (skey == "123")
            {
                await next(context);
            }
            else
            {
                context.Response.StatusCode = 401;
            }
        }
    }
}
